// rollupConfig/index.js
import ts from '@rollup/plugin-typescript'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import babel from '@rollup/plugin-babel'
import vue from 'rollup-plugin-vue'
import postcss from 'rollup-plugin-postcss'
import { eslint } from 'rollup-plugin-eslint'

const env = process.env.NODE_ENV
const extensions = ['.js', '.ts', 'tsx']

export default {
  input: 'src/main.ts'
}

export const plugins = [
  nodeResolve(),
  babel({
    exclude: 'node_modules/**',
    babelHelpers: 'bundled',
    extensions
  }),
  vue(),
  eslint({
    include: ['src/**.ts', 'src/**.tsx'],
    throwOnError: true
  }),
  ts({
    tsconfig: './tsconfig.json'
  }),
  postcss({}),
  replace({
    preventAssignment: true,
    'process.env.NODE_ENV': JSON.stringify(env),
    '__VUE_OPTIONS_API__': true,
    '__VUE_PROD_DEVTOOLS__': true
  })
]
